<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <base href="<%=basePath%>">
    <link rel="stylesheet" href="static/component/pear/css/pear.css" />
    <link rel="stylesheet" href="static/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="static/css/public.css" media="all">
</head>
<body style="margin-left:50px">
<form class="layui-form" action="">
    <div class="layui-form-item">
        <label class="layui-form-label">供应商编码</label>
        <div class="layui-input-block">
            <input style="width: 250px"  type="text" name="supplierCode"   required  lay-verify="required" placeholder="请输入供应商编码" autocomplete="off" class="layui-input"  />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">供应商名称</label>
        <div class="layui-input-block">
            <input style="width: 250px" type="text" name="supplierName" required  lay-verify="required" placeholder="请输入供应商名称" autocomplete="off" class="layui-input"  />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">介绍</label>
        <div class="layui-input-block">
            <input style="width: 250px" type="text" name="supplierDesc" required  lay-verify="required" placeholder="请输入介绍信息" autocomplete="off" class="layui-input"  />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">联系人</label>
        <div class="layui-input-block">
            <input style="width: 250px" type="text" name="supplierContact" required  lay-verify="required" placeholder="请输入联系人" autocomplete="off" class="layui-input"  />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">手机号</label>
        <div class="layui-input-block">
            <input style="width: 250px"   type="text" name="supplierPhone" required  lay-verify="phone" placeholder="请输入手机号" autocomplete="off" class="layui-input "  />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">地址</label>
        <div class="layui-input-block">
            <input style="width: 250px" type="text" name="supplierAddress" required  lay-verify="required" placeholder="请输入地址" autocomplete="off" class="layui-input "  />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">创建时间</label>
        <div class="layui-input-block">
            <input style="width: 250px" type="datetime" name="creationDate"   placeholder="请输入创建时间" autocomplete="off" class="layui-input userData"  />
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">

            <button type="button" class="layui-btn" lay-submit lay-filter="userUpdateForm">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>

<script src="static/component/layui/layui.js"></script>
<script src="static/component/pear/pear.js"></script>

<script>

    layui.use(['laydate','form'], function(){
        var laydate = layui.laydate;
        var $ = layui.jquery;
        var form = layui.form;

        //日期时间选择器
        laydate.render({
            elem: '.userData'
            ,type: 'datetime'
        });



        //异步请求添加用户信息
        form.on('submit(userUpdateForm)',function (data){
            //发送异步请求修改
            $.post('supplier/addSupplier',data.field,function (result){
                //回调
                if (result.success){
                    layer.msg(result.msg,{icon:1,time:1000},function(){
                        window.close();
                        parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                        parent.parent.location.reload(); // 父页面刷新
                        parent.layui.table.reload("user-table");
                    });
                }
            })
        });


    });
</script>

</body>
</html>